import request from '@/router/axios';
import {
    formateTime
} from '../util/date';
export const loginByUsername = (username, password, code, redomStr) => request({
    url: '/admin/security/login',
    method: 'post',
    data: {
        loginName: username,
        password: password,
        code,
        redomStr
    }
})

export const getUserInfo = () => {
    return request({
        url: '/admin/manager/manger-login-info',
        method: 'get'
    });
}

export const RefeshToken = () => request({
    url: '/user/refesh',
    method: 'post'
})

export const getMenu = (type = 0) => request({
    url: '/user/getMenu',
    method: 'get',
    data: {
        type
    }
});

export const getMenuAll = () => request({
    url: '/user/getMenu',
    method: 'get',
    data: {
        type: 0
    }
});

export const getTableData = (page) => request({
    url: '/user/getTable',
    method: 'get',
    data: {
        page
    }
});

export const logout = () => request({
    url: '/user/logout',
    method: 'get'
})
export const list = (data) => request({
    url: '/user/list',
    method: 'post',
    data
}).then(data => {
    data = data || {};
    data.rows && data.rows.forEach(item => {
        item.create_time = formateTime(item.create_time);
        item.modify_time = formateTime(item.modify_time);
        item.member_expire_time = formateTime(item.member_expire_time);
    });
    return data;
});
